package collection.stream;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: Miyako
 * @Date: 2024-07-18-15:02
 * @Description:
 */
public class StreamDemo02 {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        int s  = list.stream().filter(x->x%2==1).mapToInt(f->f).sum();
        System.out.println(s);

        s = list.stream().filter(x->x%2==0).reduce(0,(x,y)->x+y);
        System.out.println(s);
    }
}
